package leetcode.editor.cn;

public class _11_ContainerWithMostWater {
    public static void main(String[] args) {
        Solution solution = new _11_ContainerWithMostWater().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int maxArea(int[] height) {
            int l = 0, r = height.length - 1;
            int res = 0;

            while (l < r) {
                int area = Math.min(height[l], height[r]) * (r - l);
                res = Math.max(res, area);

                // 每次移动高度更低的指针 (如果移动高度更高的指针，则必然导致面积减小)
                if (height[l] <= height[r]) {
                    l++;
                } else {
                    r--;
                }
            }

            return res;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}